<template>
  <div>
    <div ref="chartsTable1" style="width: 600px; height: 400px"></div>
    <div id="main" style="width: 600px; height: 400px"></div>
    <div ref="main1" style="width: 600px; height: 400px"></div>
  </div>
</template>

<script>
export default {
  name: "one",
  mounted() {
    this.init();
  },
  methods: {
    init() {
      //基于准备好的dom，初始化chart实例（this.$refs.元素ID来获取当前元素)
      var myChart = this.$echarts.init(this.$refs.chartsTable1);
      var mychart1 = this.$echarts.init(document.getElementById("main"));
      var myChart2 = this.$echarts.init(this.$refs.main1);
      // 指定图表的配置项和数据
      var option = {
        title: {
          text: "统计表",
        },
        tooltip: {},
        legend: {
          data: ["销量"],
        },
        xAxis: {
          data: ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"],
        },
        yAxis: {},
        series: [
          {
            name: "销量",
            type: "bar",
            data: [5, 20, 36, 10, 10, 20],
          },
        ],
      };

      var option1 = {
        title: {
          text: "统计表2",
        },
        tooltip: {},
        legend: {
          data: ["单价"],
        },
        xAxis: {
          data: ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"],
        },
        yAxis: {},
        series: [
          {
            name: "单价",
            type: "bar",
            data: [50, 20, 36, 30, 100, 5],
          },
        ],
      };

      var option2 = {
        title: {
          text: "统计表3",
        },
        xAxis: {
          type: "category",
          data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
        },
        yAxis: {
          type: "value",
        },
        series: [
          {
            data: [150, 230, 224, 218, 135, 147, 260],
            type: "line",
          },
        ],
      };
      // 使用刚指定的配置项和数据显示图表。
      myChart.setOption(option);
      mychart1.setOption(option1);
      myChart2.setOption(option2);
    },
  },
};
</script>